package com.yurendao.shop.forum.web.json;

import com.yurendao.shop.forum.domain.Note;
import com.yurendao.shop.forum.domain.NotePicture;
import com.yurendao.shop.user.domain.User;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by kong on 16/1/25.
 */
public class NoteJson {

    private int errorcode;
    private Note note;
    private String currdate;
    private int commentCount;

    public NoteJson(Note note,int commentCount){
        this.note = note;
        this.commentCount = commentCount;
        Date now = new Date();
        Date before = note.getNotedate();

        long result;
        result = ((now.getTime() - before.getTime()) / (1000 * 60 * 60 * 24));
        if(result==0){
            result = ((now.getTime()-before.getTime()) / (1000 * 60 * 60));
            if(result==0){
                result = ((now.getTime()-before.getTime()) / (1000 * 60));
                currdate = result+"分钟前";
            }
            else
                currdate = result+"小时前";
        }else{
            currdate = result+"天前";
        }
    }

    public int getErrorcode() {
        return errorcode;
    }

    public void setErrorcode(int errorcode) {
        this.errorcode = errorcode;
    }

    public Note getNote() {
        return note;
    }

    public void setNote(Note note) {
        this.note = note;
    }

    public String getCurrdate() {
        return currdate;
    }

    public void setCurrdate(String currdate) {
        this.currdate = currdate;
    }

    public int getCommentCount() {
        return commentCount;
    }

    public void setCommentCount(int commentCount) {
        this.commentCount = commentCount;
    }
}
